﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Collections.ObjectModel;

namespace IMDemo.Views
{
    /// <summary>
    /// UCDialogList.xaml 的交互逻辑
    /// </summary>
    public partial class UCDialogList : UserControl
    {
        private ObservableCollection<UCDialog> dialogs;

        public ObservableCollection<UCDialog> Dialogs
        {
            get
            {
                if (this.dialogs == null)
                {
                    this.dialogs = new ObservableCollection<UCDialog>();
                }

                return this.dialogs;
            }
        }

        public UCDialog SelectedDialog
        {
            get { return (UCDialog)GetValue(SelectedDialogProperty); }
            set { SetValue(SelectedDialogProperty, value); }
        }

        // Using a DependencyProperty as the backing store for SelectedDialog.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty SelectedDialogProperty =
            DependencyProperty.Register("SelectedDialog", typeof(UCDialog), typeof(UCDialogList), new PropertyMetadata(null,new PropertyChangedCallback(SelectedDialogPropertyChanged)));

        private static void SelectedDialogPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            UCDialog dialog = (UCDialog)e.NewValue;
            dialog.NoReadMessageList.Clear();
        }

        public UCDialogList()
        {
            InitializeComponent();
            this.DataContext = this;
        }
    }
}
